import sys
sys.path.append('../PIProxy')

from PIProxy import PIProxyService
from PIProxy.ttypes import *

from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol


if __name__ == '__main__':
    print 'start'

    # Make socket
    transport = TSocket.TSocket('localhost', 9090)
    
    # Buffering is critical. Raw sockets are very slow
    transport = TTransport.TBufferedTransport(transport)
    
    # Wrap in a protocol
    protocol = TBinaryProtocol.TBinaryProtocol(transport)

    # Create a client to use the protocol encoder
    client = PIProxyService.Client(protocol)
    
    # Connect!
    transport.open()
    
    rs = client.GetPointSnapShot(14420)
    print rs
    